home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 2: CDPD 1 / Almathera Ten on Ten - Disc 2: CDPD 1.iso / pd / 201-225 / 204 / hamcu / hamcu.c < prev    next >
C/C++ Source or Header  |  1995-03-13  |  2KB  |  78 lines

  1. #include <stdio.h>
  2. #include <exec/types.h>
  3. #include <exec/memory.h>
  4. #include <graphics/gfxbase.h>
  5. #include <graphics/copper.h>
  6. #include <graphics/gfxmacros.h>
  7. #include <hardware/custom.h>
  8. #include <intuition/intuition.h>
  9. #include <exec/ports.h>
  10.  
  11. struct IntuitionBase *IntuitionBase;
  12. struct GfxBase *GfxBase;
  13. struct ViewPort *MyView;
  14. struct UCopList *MyList;
  15. char confile[]="CON:90/60/460/60/HAMCu by Jonathan Potter";
  16. FILE *con;
  17.  
  18. void main(argc,argv)
  19. int argc;
  20. char **argv;
  21. {
  22.     int c=0,x,y,bc;
  23.     struct MsgPort *port;
  24.  
  25.     if (argc==0) {
  26.         con=fopen(confile,"w+");
  27.         if (con==NULL) exit(10);
  28.     }
  29.     else con=stdout;
  30.     IntuitionBase=(struct IntuitionBase *) OpenLibrary("intuition.library",0);
  31.     GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",0);
  32.     MyView=GfxBase->ActiView->ViewPort;
  33.     MyList=AllocMem(sizeof(struct UCopList),MEMF_PUBLIC|MEMF_CLEAR);
  34.   bc=(((GetRGB4(MyView->ColorMap,0)>>8)&0xf)*256)+
  35.         (((GetRGB4(MyView->ColorMap,0)>>4)&0xf)*16)+
  36.       ((GetRGB4(MyView->ColorMap,0))&0xf);
  37.     fprintf(con,"\n\n\x9B;0;1mHAM\x9B;33mCu\x9B;0m  by Jonathan Potter\n\n");
  38.     if ((port=FindPort("HAMCu.port"))==NULL) {
  39.         if ((port=CreatePort("HAMCu.port",0))==NULL) {
  40.             fprintf(con,"Can't create message port\n");
  41.             for (x=0;x<30000;x++);
  42.             CloseLibrary(GfxBase);
  43.             CloseLibrary(IntuitionBase);
  44.             if (argc==0) fclose(con);
  45.             exit(10);
  46.         }
  47.         fprintf(con,"Please wait.. installing \x9B;0;1;33mCopper\x9B;0m list..\n");
  48.         for (y=0;y<256;y++) {
  49.             for (x=0;x<224;x=x+14) {
  50.                 CWAIT(MyList,y,x);
  51.                 CMOVE(MyList,custom.color[0],c);
  52.                 ++c;
  53.                 if (c==0x1000) {
  54.                     CWAIT(MyList,y,x+14);
  55.                     CMOVE(MyList,custom.color[0],bc);
  56.                     goto endlist;
  57.                 }
  58.             }
  59.         }
  60.         endlist:
  61.         CEND(MyList);
  62.         MyView->UCopIns=MyList;
  63.         RethinkDisplay();
  64.         if (argc==0) fclose(con);
  65.         CloseLibrary(IntuitionBase);
  66.         CloseLibrary(GfxBase);
  67.         exit(0);
  68.     }
  69.     fprintf(con,"Please wait.. removing \x9B;0;1;33mCopper\x9B;0m list..\n");
  70.     for (x=0;x<30000;x++);
  71.     MyView->UCopIns=NULL;
  72.     RethinkDisplay();
  73.     if (argc==0) fclose(con);
  74.     DeletePort(port);
  75.     CloseLibrary(IntuitionBase);
  76.     CloseLibrary(GfxBase);
  77. }
  78.